﻿/*
* edirauth - http://edirauth.codeplex.com
* A .NET library and utility for authenticating to eDirectory
* Copyright (c) 2013 Matt Shirilla (http://shirilla.com)
* Licensed under the Microsoft Public License (MS-RL)
* http://edirauth.codeplex.com/license
*/

using System;
using System.Configuration;
using edirAuth;
using Novell.Directory.Ldap;
using System.Collections.Specialized;

namespace edirAuthTests
{
    /// <summary>
    /// *******************************    IMPORTANT TEST SETUP NOTICE  ******************************** 
    /// Import the .ldif file into your eDIrectory to create the test accounts needed for this test. It
    /// is okay to make changes to the accounts, just be sure to edit the app.config file for this 
    /// project with the values.
    /// ************************************************************************************************ 
    /// </summary>
    class Helper
    {
        static EdirAuthorizer edirAuthorizer=null;
        public static string TESTUSER01_UID;
        public static string TESTUSER02_UID;
        public static string TESTUSER03_UID;
        public static string TESTUSER04_UID;
        public static string TESTUSER01_DN;
        public static string TESTUSER02_DN;
        public static string TESTUSER03_DN;
        public static string TESTUSER04_DN;
        public static string TESTUSERS_PASSWORD;

        public static string INVALIDBINDUSERFORMAT;
        public static string INVALIDBINDUSER;
        public static string INVALIDBINDSERVER;

        /// <summary>
        /// EdirAuthorizer Factory for all test classes
        /// </summary>
        internal static EdirAuthorizer EdirAuthorizerFactory() {
            Helper.edirAuthorizer = new EdirAuthorizer(
                ConfigurationManager.AppSettings["ldapServer"],
                Convert.ToInt16(ConfigurationManager.AppSettings["ldapPort"]),
                ConfigurationManager.AppSettings["bindUser"],
                ConfigurationManager.AppSettings["bindPass"],
                ConfigurationManager.AppSettings["searchBase"],
                ConfigurationManager.AppSettings["lookupAttrName"]
            );


            var testSettings = ConfigurationManager.GetSection("TestSettings") as NameValueCollection;
            if (testSettings != null) {
                Helper.TESTUSER01_UID = testSettings["testuser01uid"].ToString();
                Helper.TESTUSER02_UID = testSettings["testuser02uid"].ToString();
                Helper.TESTUSER03_UID = testSettings["testuser03uid"].ToString();
                Helper.TESTUSER04_UID = testSettings["testuser04uid"].ToString();
                Helper.TESTUSER01_DN = testSettings["testuser01dn"].ToString();
                Helper.TESTUSER02_DN = testSettings["testuser02dn"].ToString();
                Helper.TESTUSER03_DN = testSettings["testuser03dn"].ToString();
                Helper.TESTUSER04_DN = testSettings["testuser04dn"].ToString();
                Helper.TESTUSERS_PASSWORD = testSettings["testusers_password"].ToString();
                Helper.INVALIDBINDUSERFORMAT = testSettings["invalidbinduserformat"].ToString();
                Helper.INVALIDBINDUSER = testSettings["invalidbinduser"].ToString();
                Helper.INVALIDBINDSERVER = testSettings["invalidbindserver"].ToString();
            }
            return edirAuthorizer;
        }
        
    
    }//class
}//namespace
